import time

from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
money ='10000'
money_info = '买手机用'
testCase = "DBshop034"
firefox = openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,'客户管理','管理客户')

num1=firefox.find_element_by_xpath('//td[contains(text(),"huxian")][1]/following-sibling::td[5]').text
print(num1)
firefox.find_element_by_xpath('//td[contains(text(),"huxian")][1]/following-sibling::td[7]/a[2]').click()
firefox.find_element_by_name('money_change_num').send_keys(money)
firefox.find_element_by_id('money_pay_info').send_keys(money_info)
firefox.find_element_by_xpath('//button[text()="提交充值"]').click()

time.sleep(5)

firefox.get(url)
DBshopLogin(firefox,'huxian','123456')
firefox.find_element_by_link_text('用户中心').click()
firefox.find_element_by_link_text('账户余额').click()

l="￥"
r="元"
s=firefox.find_element_by_xpath('//body').text

num2=reGetString(s,l,r)
print(num2)
try:
    int(num2)-int(num1)==int(money)
    writeLog("%s 测试通过" % testCase)
except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)

firefox.quit()